<!DOCTYPE html>
<html lang="pt-BR">
    <head>
        <?php
        session_start();
        include_once'bloco/head.php';
        include_once '../control/conexao.php';

        function __autoload($classe) {
            include_once"../model/{$classe}.class.php";
        }
        ?>
        <link href="bootstrap/css/morris.css" rel="stylesheet">

    </head>
    <body>      
        <div id="wrapper">
            <?php include_once'bloco/navbar.php'; ?>
            <div id="page-wrapper">
                <?php include_once 'bloco/banner.php'; ?>                
                <div class="row">
                    <div class=" panel panel-success">
                        <div class="panel-heading">
                            <p class="panel-title"><i class = "glyphicon glyphicon-th-large"></i> Cadastrar Empresa</p>
                        </div>
                        <div class="panel-body">
                            <div class="col-lg-12">
                                <form autocomplete="off" class="form-cadastra-empresa" role="form" name="form_cadastra_empresa" method="post" action="../control/cadastrar_empresa.php">                                    
                                    <input type="hidden" value="4" name="perfil">
                                    <div class="row">
                                        <div class="col-md-8 col-md-offset-2">
                                            <div class="alert alert-success alert-dismissable">
                                                <table class="table table-responsive">
                                                    <tr>
                                                        <td><strong>Senha de Acesso</strong></td>
                                                        <td><input type="password" name="senha" class="form-control" required autofocus></td>
                                                    </tr>   
                                                </table>
                                            </div>
                                            <div class="alert alert-success alert-dismissable">
                                                <table class="table table-responsive">
                                                    <tr>
                                                        <td><strong>Sigla / Nome Fantasia</strong></td>
                                                        <td><input type="text" name="sigla" class="form-control" required autofocus maxlength="20"></td>
                                                    </tr>
                                                    <tr>
                                                        <td><strong>Razão Social</strong></td>
                                                        <td><input type="text" name="razao" class="form-control" required autofocus></td>
                                                    </tr>
                                                    <tr>
                                                        <td><strong>CNPJ</strong></td>
                                                        <td><input type="text" id="cnpj" name="cnpj" maxlength="17" class="form-control" required autofocus onkeyup="mascara_cnpj_cadastra(this)"> </td>
                                                    </tr>
                                                    <tr>
                                                        <td></td>
                                                        <td></td>
                                                    </tr>
                                                </table>
                                            </div>                                               
                                            <div class="alert alert-success alert-dismissable">
                                                <table class="table">
                                                    <tr>
                                                        <td><strong>Endereço</strong></td>
                                                        <td><input type="text" name="endereco" class="form-control" required autofocus></td>
                                                    </tr>
                                                    <tr>
                                                        <td><strong>CEP</strong></td>
                                                        <td><input type="text" id="cep" name="cep" class="form-control" required autofocus></td>
                                                    </tr>
                                                    <tr>
                                                        <td><strong>Bairro</strong></td>
                                                        <td><input type="text" name="bairro" class="form-control" required autofocus> </td>
                                                    </tr>
                                                    <?php
                                                    $res = mysql_query("SELECT * FROM estados ORDER BY sigla");
                                                    $num = mysql_num_rows($res);
                                                    while ($dados = mysql_fetch_array($res)) {
                                                        $id_estado[] = $dados['id_estado'];
                                                        $estado_nome[] = (utf8_encode($dados['nome']));
                                                    }
                                                    ?>
                                                    <tr>
                                                        <td><label>Estado:</label></td>
                                                        <td>
                                                            <select name="estado" id="estado" onchange="buscar_cidades()" class='btn btn-block'>                                
                                                                <option value="">Selecione...</option>
                                                                <?php
                                                                for ($i = 0; $i < $num; $i++) {
                                                                    ?>
                                                                    <option value="<?php echo $id_estado[$i] ?>"><?php echo $estado_nome[$i] ?></option>
                                                                <?php } ?>                                
                                                            </select>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td><label>Cidades:</label></td>
                                                        <td>
                                                            <select id="load_cidades" name="cidade" id="cidade" class='btn btn-block'>
                                                                <option value="">Selecione...</option>
                                                            </select>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </div>                                            
                                            <div class="alert alert-success alert-dismissable">
                                                <table class="table">
                                                    <tr>
                                                        <td><strong>E-mail</strong></td>
                                                        <td><input type="email" name="email" class="form-control" required autofocus></td>
                                                    </tr>
                                                    <tr>
                                                        <td><strong>Telefone</strong></td>
                                                        <td><input type="text" id="telefone" name="telefone" class="form-control" required autofocus></td>
                                                    </tr>
                                                </table>
                                            </div>
                                            <div class="alert alert-success alert-dismissable">
                                                <table class="table">
                                                    <tr>
                                                        <td><strong>Nome do Responsável</strong></td>
                                                        <td><input type="text" name="nome_resp" class="form-control" required autofocus></td>
                                                    </tr>
                                                    <tr>
                                                        <td><strong>Cargo do Responsável</strong></td>
                                                        <td><input type="text" name="cargo_resp" class="form-control" required autofocus></td>
                                                    </tr>
                                                    <tr>
                                                        <td><strong>Especialização do Responsável</strong></td>
                                                        <td><input type="text" name="especializacao_resp" class="form-control" required autofocus></td>
                                                    </tr>
                                                </table>
                                            </div>
                                            <?php $data = date('Y,m,d') ?>
                                            <input type="hidden" name="data" value="<?php echo $data ?>">
                                            <div align="center">
                                                <input type="button" class="btn btn-inverse" value="Voltar" onclick="history.go(-1)"/>
                                                <input type="submit" class="btn btn-success" value="Cadastrar"/>
                                            </div>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <?php
        include_once'bloco/scripts.php';
        ?>
        <script src="bootstrap/js/busca_cidades.js"></script>
        <!--<script src="bootstrap/js/mascaras.js"></script>-->
        <script src="bootstrap/js/mask/mask.js"></script>
        <script>
                                                    jQuery(function($) {
                                                        $("#cnpj").mask("99.999999/9999-99");
                                                        $("#telefone").mask("(99) 9999-9999");
                                                        $("#cep").mask("99999-999");
                                                    });
        </script>
    </body>
</html>
